const { lstatSync, readFileSync } = require('fs');
const _ = require('lodash');

module.exports = function loadJson(file) {
  try {
    if (lstatSync(file).isFile()) {
      const buffer = readFileSync(file);
      const json = JSON.parse(buffer);
      return _.isPlainObject(json) && Object.keys(json).length > 0 ? json : false;
    }
  } catch (e) {
    return false;
  }
};